﻿using jinmaMesProxy.Model;
using jinmaMesProxy.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace jinmaMesProxy.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class MaterialAppVouchController: MyController
    {
        MaterialAppVouchService materialAppVouchService = new MaterialAppVouchService();
        [HttpPost, Authorize]
        public ResponseData<MaterialAppVouch> Save(MaterialAppVouch data)
        {
            materialAppVouchService.Save(data);
            return new ResponseData<MaterialAppVouch>([data]);
        }

        [HttpGet,HttpPost, Authorize]
        public ResponseData<MaterialAppVouch> GetByCode(string code)
        {
            return new ResponseData<MaterialAppVouch>([materialAppVouchService.GetByCode(code)]);
        }
        [HttpPost, Authorize]
        public ResponseData<string> DelByCode(string code)
        {
            materialAppVouchService.Delete(code);
            return new ResponseData<string>(["操作成功"]);
        }
    }
}
